package com.ruoyi.wechat.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wechat.domain.Communicationid;
import com.ruoyi.wechat.service.ICommunicationidService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 营地交流Controller
 * 
 * @author ruoyi
 * @date 2024-12-31
 */
@RestController
@RequestMapping("/wechat/communicationid")
public class CommunicationidController extends BaseController
{
    @Autowired
    private ICommunicationidService communicationidService;

    /**
     * 查询营地交流列表
     */
    @PreAuthorize("@ss.hasPermi('wechat:communicationid:list')")
    @GetMapping("/list")
    public TableDataInfo list(Communicationid communicationid)
    {
        startPage();
        List<Communicationid> list = communicationidService.selectCommunicationidList(communicationid);
        return getDataTable(list);
    }

    /**
     * 导出营地交流列表
     */
    @PreAuthorize("@ss.hasPermi('wechat:communicationid:export')")
    @Log(title = "营地交流", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Communicationid communicationid)
    {
        List<Communicationid> list = communicationidService.selectCommunicationidList(communicationid);
        ExcelUtil<Communicationid> util = new ExcelUtil<Communicationid>(Communicationid.class);
        util.exportExcel(response, list, "营地交流数据");
    }

    /**
     * 获取营地交流详细信息
     */
    @PreAuthorize("@ss.hasPermi('wechat:communicationid:query')")
    @GetMapping(value = "/{communicationId}")
    public AjaxResult getInfo(@PathVariable("communicationId") String communicationId)
    {
        return success(communicationidService.selectCommunicationidByCommunicationId(communicationId));
    }

    /**
     * 新增营地交流
     */
    @PreAuthorize("@ss.hasPermi('wechat:communicationid:add')")
    @Log(title = "营地交流", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Communicationid communicationid)
    {
        return toAjax(communicationidService.insertCommunicationid(communicationid));
    }

    /**
     * 修改营地交流
     */
    @PreAuthorize("@ss.hasPermi('wechat:communicationid:edit')")
    @Log(title = "营地交流", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Communicationid communicationid)
    {
        return toAjax(communicationidService.updateCommunicationid(communicationid));
    }

    /**
     * 删除营地交流
     */
    @PreAuthorize("@ss.hasPermi('wechat:communicationid:remove')")
    @Log(title = "营地交流", businessType = BusinessType.DELETE)
	@DeleteMapping("/{communicationIds}")
    public AjaxResult remove(@PathVariable String[] communicationIds)
    {
        return toAjax(communicationidService.deleteCommunicationidByCommunicationIds(communicationIds));
    }
}
